//
//  XJStatusToolBar.m
//  weiboOC
//
//  Created by 徐绩 on 16/4/23.
//  Copyright © 2016年 ayumi. All rights reserved.
//

#import "XJStatusToolBar.h"

@implementation XJStatusToolBar

-(instancetype)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}

-(void)setupUI{

    UIButton *retweetBtn = [self addChildBtn:@"转发" imageName:[UIImage imageNamed:@"timeline_icon_retweet"]];
    UIButton *commentBtn = [self addChildBtn:@"评论" imageName:[UIImage imageNamed:@"timeline_icon_comment"]];
    UIButton *likeBtn = [self addChildBtn:@"赞" imageName:[UIImage imageNamed:@"timeline_icon_unlike"]];
    
    UIImageView *sp1 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"timeline_card_bottom_line"]];
    UIImageView *sp2 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"timeline_card_bottom_line"]];
    [self addSubview:sp1];
    [self addSubview:sp2];
    
    [retweetBtn makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.top.bottom.equalTo(self);
        make.width.equalTo(commentBtn);
    }];
    [commentBtn makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(retweetBtn.trailing);
        make.top.bottom.equalTo(self);
        make.width.equalTo(likeBtn);
    }];
    [likeBtn makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(commentBtn.trailing);
        make.top.bottom.equalTo(self);
        make.trailing.equalTo(self);
        make.width.equalTo(retweetBtn);
    }];
    [sp1 makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(retweetBtn.trailing);
        make.centerY.equalTo(self);
    }];
    [sp2 makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(commentBtn.trailing);
        make.centerY.equalTo(self);
    }];

}

-(UIButton *)addChildBtn:(NSString *)title imageName:(UIImage *)imageName{

    UIButton *btn = [[UIButton alloc]init];
    [btn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setImage:imageName forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"timeline_card_bottom_background"] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"timeline_card_bottom_background_highlighted"] forState:UIControlStateHighlighted];
    btn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:btn];
    
    return btn;
}

@end
